package com.heima.controller;

import com.github.pagehelper.Page;
import com.heima.pojo.dto.CollaboratorDTO;
import com.heima.pojo.dto.CollaboratorPageDTO;
import com.heima.pojo.vo.CollaboratorVO;
import com.heima.pojo.vo.PageSearchQueryVO;
import com.heima.service.CollaboratorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/user-service/partner")
@Api(tags = "合作商管理接口")
public class CollaboratorController {

    @Autowired
    CollaboratorService collaboratorService;
    /**
     * 新增合作商
     * **/
    @ApiOperation("新增合作商")
    @PostMapping
    public Boolean add(@RequestBody CollaboratorDTO dto){
        collaboratorService.add(dto);
        return true;
    }
    /**
    * 合作商分页查询
    * **/
    @ApiOperation("合作商分页查询")
    @GetMapping("/search")
    public PageSearchQueryVO query(CollaboratorPageDTO dto){
        PageSearchQueryVO vo  = collaboratorService.query(dto);
        return vo;
    }
/**
 * 删除合作商
 * **/
    @ApiOperation("删除合作商")
    @DeleteMapping("{id}")
    public Boolean deldeteId(@PathVariable("id") Integer id){
        collaboratorService.deleyeId(id);
        return true;
    }
    @GetMapping("{id}")
    public Boolean getid(@PathVariable Integer id){
        collaboratorService.getId(id);
        return true;
    }
    /**
     * 修改合作商信息
     * **/
    @ApiOperation("修改合作商信息")
    @PutMapping("{id}")
    public Boolean upd( @PathVariable Integer id,@RequestBody CollaboratorDTO dto){
        collaboratorService.upd(id,dto);
        return true;
    }
    
}
